package net.dianpin.task;

import net.dianpin.dao.generate.CompanyMapper;
import net.dianpin.model.generate.Company;
import net.dianpin.model.generate.CompanyExample;
import net.dianpin.util.DAOUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * Created by lei on 2014/6/2.
 */
public class CompanyTask {
    private static Logger logger = Logger.getLogger(CompanyTask.class);

    private static void addCompany(){
        CompanyMapper companyMapper = (CompanyMapper) DAOUtil.getMapperInstance(CompanyMapper.class);

        Company company = new Company();
        company.setCompanyName("上海必胜客有限公司杭州萧山金城路店");
        company.setPassword("123456");
        company.setTelephone("15658153613");
        company.setEmail("lo2007@126.com");
        company.setAddress("杭州萧山区金城路451号颐高数码广场一楼必胜客宅急送");
        company.setBusinessLicense("营业执照");
        company.setState(0);


        companyMapper.insert(company);
        CompanyExample companyExample = new CompanyExample();
        CompanyExample.Criteria criteria = companyExample.createCriteria();
        criteria.andCompanyIdGreaterThan(0);

        List<Company> companyList = companyMapper.selectByExample(companyExample);
        System.out.println(companyList.size());
    }

    public static void main(String[] args) {
        addCompany();
    }
}
